<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html>
<html lang="en">
    <head>        
        <!-- META SECTION -->
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        
        <link rel="icon" href="favicon.ico" type="image/x-icon" />
        <!-- END META SECTION -->
        
        <!-- CSS INCLUDE -->        
        <link rel="stylesheet" href="${ctx}/rs/css/bootstrap-table.css" />
        <link rel="stylesheet" href="${ctx}/rs/css/main.css" />
        <link id="theme" rel="stylesheet" href="${ctx}/rs/joli/css/theme-default.css" />
        <!-- EOF CSS INCLUDE -->       
        <style type="text/css">
            #m-info {
                position: absolute;
                top: 0;left: 0;
                /*background-color: rgba(0,0,0,.7);*/
                width: 350px;height: 400px;
                /*color: #fff;
                padding:10px;
                font-size: 12px;*/
                display: none;
            }
            #m-info img { width:100%;}
        </style>                             
    </head>
<body>
    
    <!-- START PAGE CONTAINER -->
        <div class="page-container">
            <!-- 引入左菜单部分 -->
            <jsp:include page="../joli/menu.jsp"></jsp:include>
            
            <!-- START PAGE CONTENT -->
            <div class="page-content">
                
                <jsp:include page="../joli/top.jsp"></jsp:include>
                
                <!-- START BREADCRUMB -->
                <ul class="breadcrumb">
                    <li><a href="#">意见反馈</a></li>                    
                    <li class="active">广告意见反馈</li>
                </ul>
                <!-- END BREADCRUMB -->   
                
                
                <!-- PAGE CONTENT WRAPPER -->
                <div class="page-content-wrap">
                    <div class="row">
                        <div class="col-xs-12">
                            <div id="toolbar">
                                <div class="fr pb10">
                                   <a href ="send.htm?page=feedback/adverNotList">未回复</a>
                                <a href ="send.htm?page=feedback/adverIsList"><b>已回复</b></a>
                             <select class="srt-put1 mr10 widput1" id="feedrefresh" >
                                    <option value="user_name">客户名称</option>
                                    <option value="user_email">账号</option>
                                    <option value="create_time">发布日期</option>
                                </select>
                                  <input type="text" class="srt-put1 mr10 widput1" id="key" name="key"/>
                                  <button class="btn btn-primary btn-sm srt-btn active" onclick="refresh()">搜索</button>
                                </div>
                            </div>
                            
                            <table id="table" cellpadding="0" cellspacing="0" data-toggle="table" data-toolbar="#toolbar"
                                data-url="${ctx}/Feedbac/getAdverisFeedbackMessList.htm"
                                data-cache="false"
                                data-pagination="true" 
                                data-side-pagination="server"
                                data-page-list="[10, 20, 50, 100]"
                                data-page-size="20"  
                                data-query-params="queryParams">
                                <thead>
                                    <tr class="tab-th">
                                        <!-- <th data-field="state" data-checkbox="true"></th> -->
                                        <th data-field="id" >编号</th>
                                        <th data-field="user_name" class="col-md-2">客户名称</th>
                                        <th data-field="user_email" class="col-md-2">发布账号</th>
                                        <th data-field="create_time" data-formatter="timeFormatter" class="col-md-2">反馈时间</th>
                                        <th data-field="feedback_content" data-formatter="titlesubstring" class="col-md-3">反馈内容</th>
                                        <th data-field="action" data-formatter="actionFormatter" class="col-md-1">操作</th>
                                    </tr>
                                </thead>
                            </table>
                        </div>
                    </div>
                </div>
        </div>
        <div id="m-info"></div>
    
        
    <!-- 引入所有joli的脚本 -->
    <jsp:include page="../joli/scripts.jsp"></jsp:include>
    <!-- 引入页面需要的脚本 -->
    <script type="text/javascript" src="${ctx}/rs/js/bootstrapQ.min.js"></script>
    <script src="${ctx}/rs/js/bootstrap-table.js"></script>
    <script src="${ctx}/rs/js/bootstrap-table-zh-CN.js"></script>
    <script src="${ctx}/rs/js/jquery.formatDate.js"></script>
    <%-- <script src="${ctx}/rs/js/my97DatePicker/WdatePicker.js"></script> --%>
    <script language="javascript" type="text/javascript" src="${ctx}/rs/js/my97DatePicker/WdatePicker.js"></script>
    <script type="text/javascript" src="${ctx}/rs/js/session-out-error.js"></script>
    <script>
    
      activeMenu($("#menu_feedback_1"));
      var $table = $('#table');
      
      $table.on('click-row.bs.table', function (e, row, $element) {
            $table.bootstrapTable('uncheckAll');
            $table.bootstrapTable('check', $element.index());
      });
      
      $table.bootstrapTable({
          height: getHeight()
      });
        
      //获取分辨率高度
        function getHeight() {
            return window.screen.height - 308;
        }
        
        $(window).resize(function () {
        $table.bootstrapTable('resetView',{height: getHeight()});
      });
        
        //初始化刷新
         function refresh(pageIndex,selectPage){
        	 var key=$("#key").val();
             var feedrefresh = $("#feedrefresh").val();
            if(!pageIndex && !selectPage){
                pageIndex = 0;
                selectPage = 0;
            }
            var pageSize = $table.bootstrapTable('getOptions').pageSize;
            pageIndex=pageIndex*pageSize;
            $table.bootstrapTable('refresh', {
                silent: true,
                cache : false, 
                url: '${ctx}/Feedbac/getAdverisFeedbackMessList.htm',
                contentType:'application/x-www-form-urlencoded; charset=UTF-8',
                query: {
                	key:encodeURI(key),
                    feedrefresh:feedrefresh,
                    pageIndex : pageIndex,
                    pageSize : pageSize
                   
                }
           });
            $table.bootstrapTable('selectPage', selectPage);
        }
        
        
        function reject(id,status){
                  $("#modal1").modal("show");
                  $(".btnAjax").on('click',function(){
                      var feedback_content = $(".feedback_content").val();
                      if(!feedback_content){
                            alert("请填写回复内容！");
                            return;
                        }
                      if(feedback_content.length>500){
                          alert("内容不超过500个字");
                          return;
                      }
                      $.ajax({
                           url: "${ctx}/Feedbac/save.htm", 
                          type: 'POST',
                          data: {
                              id:id,
                              feedback_content:feedback_content
                          },
                            success: function (text) {
                                bootstrapQ.msg({
                                    msg  : '操作成功！',
                                    type : 'success',
                                    time : 2000
                                });
                                setTimeout("window.location.reload(true)",2000);
                            },
                            error: function () {
                                bootstrapQ.msg({
                                    msg  : '操作失败！',
                                    type : 'danger',
                                    time : 2000
                                });
                                setTimeout("window.location.reload(true)",1000);
                            } 
                     }); 
                  })
        }
       
        function queryParams(params) {
            return {
                pageIndex : params.offset,
                pageSize : params.limit
            };
        }
       
        
        function timeFormatter(value, row, index){
             if(value){
                 return $.formatDate("yyyy-MM-dd HH:mm:ss", new Date(value));
             }
             return "--";
        }
        
        function actionFormatter(value, row, index){
            return '<a class="mr15" href="javascript:feedis('+row.id+')">回复</a>';
        }
        function titlesubstring(value, row, index){
            var statusName ="";
            if(value!=""&&value!=null){
           if(value.length>10){
                statusName = "<span title='"+value+"'>"+value.substring(0,10)+"</span>";
                return statusName ;
            }
               return value;
            }
               return "--";            
       }
        
        function feedis(id) {
            bootstrapQ.dialog({
                url : "${ctx}/Feedbac/getfeedcontent.htm?id="+ id,
                title : "回复详情",
                width: '720px',
                close : 'true',
                hidebtn : 'true'
            },function(){
                //回调触发关闭窗口
                $("#bsmodal").modal("hide");
                refresh(pageIndex,pageNumber);
            });
    }
    </script>
</body>
</html>
